<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;

/**
 * Class GoodsStockLog
 * 
 * @property int $id
 * @property int $goods_id
 * @property int $count
 * @property bool $type
 * @property Carbon|null $create_at
 *
 * @package App\Models
 */
class GoodsStockLog extends BaseModels
{
	protected $table = 'zh_goods_stock_log';

	protected $casts = [
		'goods_id' => 'int',
		'count' => 'int',
		'type' => 'int'
	];

    const UPDATED_AT = null;

	protected $fillable = [
		'goods_id',
		'count',
		'type',
		'create_at'
	];

	const MANAGER = 1; //后台管理员变更

	const BUY = 2; //用户下单扣除

	const REFUSE = 3; //取消订单回增


    protected $appends = [
        'type_string'
    ];


    /**
     * @return string
     */
    public function getTypeStringAttribute()
    {
        switch ($this->type){
            case self::MANAGER:
                return '后台管理员变更';
            case self::BUY:
                return '用户下单扣除';
            case self::REFUSE:
                return '取消订单回增';
            default:
                return '未知';
        }
    }
}
